package com.msmall.community.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.msmall.base.util.ConstantDB;
import com.msmall.community.ApplicationManager;
import com.msmall.community.vote.service.VoteManager;

public class VoteTag extends TagSupport {

	private static final long serialVersionUID = -131181397178917083L;

	private String type; // travel旅游达人

	private Long userid;
	
	public int doEndTag() throws JspException {
		JspWriter writer = pageContext.getOut();
		String ctx = ((HttpServletRequest)pageContext.getRequest()).getContextPath();
		String info = "";
		try{
			VoteManager vm = (VoteManager)ApplicationManager.appContext.getBean("voteManager");
			if("travel".equalsIgnoreCase(type)){
				Integer total = vm.loadTotalVote(userid, ConstantDB.VOTE_MODULE_TRAVEL, ConstantDB.VOTE_TYPES_POSITIVE);
				info = String.valueOf(total);
			}
			writer.print(info);
		}catch(Exception e){
			
		}
		return (SKIP_BODY);
	}
	
	public int doStartTag() throws JspException {
		return (SKIP_BODY);
	}
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Long getUserid() {
		return userid;
	}

	public void setUserid(Long userid) {
		this.userid = userid;
	}
}
